<script src="../../../router/index.js"></script>
<template>
  <div>
<!--    <base-table-restful :rows.sync="rows" :api="api" :fields="fields" baseUrl="/code/moduleInf" :btns="btns"></base-table-restful>-->
    <el-row :gutter="8" style="margin-top: 16px;">
      <el-col :span="8">
        <module-inf-tree></module-inf-tree>
      </el-col>
      <el-col :span="16">
        <base-table-restful :is-search="false" :rows.sync="rows" :api="api" :fields="fields" baseUrl="/code/moduleInf" :btns="btns"></base-table-restful>
      </el-col>
    </el-row>

    <el-dialog center title="数据表维护" :visible.sync="show" append-to-body>
      <table-inf :is-search="false" :rows.sync="tables"></table-inf>
    </el-dialog>
  </div>
</template>

<script>
  import { saveModuleInf, getModuleInfs, deleteModuleInf, updateModuleInf } from '../../../api/code'
  import moduleInf from './mixins/module-inf'
  import tableInf from '../table-inf/table-inf'
  import moduleInfTree from './module-inf-tree'

  export default {
    name: "module-inf",
    components: {tableInf, moduleInfTree},
    mixins: [moduleInf],
    data() {
      return {
        api: {
          save: saveModuleInf,
          query: getModuleInfs,
          delete: deleteModuleInf,
          update: updateModuleInf
        },
        btns: [
          {
            title: '数据表维护',
            click: (rows, handle) => {
              if (rows.length === 1) {
                const row = rows[0]
                this.tables = row.tables
                this.show = true;
              } else {
                this.$message({
                  message: '请选择一个模块',
                  showClose: true,
                  type: 'warning'
                })
              }
            }
          }
        ],
        show: false,
        tables: []
      }
    }
  }
</script>

<style scoped>

</style>
